/*


Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE!  THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required.  Any new fields you add must have json tags for the fields to be serialized.

type CkePatchDetail struct {
	Priority         int                 `json:"priority,omitempty"`
	FromVersion      string              `json:"fromVersion,omitempty"`
	ToVersion        string              `json:"toVersion,omitempty"`
	Image            string              `json:"image,omitempty"`
	Patches          []string            `json:"patches,omitempty"`
	ComponentPatches []CkeComponentPatch `json:"componentPatches,omitempty"`
}

type CkeComponentPatch struct {
	Name       string            `json:"name,omitempty"`
	ToVersion  string            `json:"toVersion,omitempty"`
	ToImageTag string            `json:"toImageTag,omitempty"`
	Parameters map[string]string `json:"parameters,omitempty"`
}

type CkePatchListDetail struct {
	Image  string                `json:"image,omitempty"`
	Patchs []CkePatchInformation `json:"patchs,omitempty"`
}

// CkePatchStatus defines the observed state of CkePatch
type CkePatchStatus struct {
	ActiveComponentPatches    []CkeComponentPatch `json:"activeComponentPatches,omitempty"`
	CompletedPatchs           []string            `json:"completedPatchs,omitempty"`
	FailedComponentPatches    []CkeComponentPatch `json:"failedComponentPatches,omitempty"`
	CompletedComponentPatches []CkeComponentPatch `json:"completedComponentPatches,omitempty"`
}

type CkePatchInformation struct {
	Name   string `json:"name,omitempty"`
	Status string `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:printcolumn:name="PRIORITY",type="number",JSONPath=".spec.priority"
// +kubebuilder:printcolumn:name="FromVERSION",type="string",JSONPath=".spec.fromVersion"
// +kubebuilder:printcolumn:name="ToVERSION",type="string",JSONPath=".spec.toVersion"
// +kubebuilder:printcolumn:name="IMAGE",type="string",JSONPath=".spec.image"

// CkePatch is the Schema for the ckepatches API
type CkePatch struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   CkePatchDetail `json:"spec,omitempty"`
	Status CkePatchStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// CkePatchList contains a list of CkePatch
type CkePatchList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []CkePatch `json:"items"`
}

func init() {
	SchemeBuilder.Register(&CkePatch{}, &CkePatchList{})
}
